<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>统战成员学习平台</title>
	<link rel="stylesheet" type="text/css" href="../css/base.css" />
	<link rel="stylesheet" type="text/css" href="../css/discovery.css" />
</head>

<body>
	<div id='app' style="display:none" v-show="true">
		<header class="red">
			<div class="ui_border_b">
				<p>发现</p>
			</div>
		</header>
		<div>
			<div class="user_form">
				<div class="item-group">
					<div class="item ui_border_t right" @click="openWin('./discovery/discovery_win')">
						<i class="icon icon_xxq"></i> 学习圈
						<span v-if="isLogin && msgCount>0" class="num">{{msgCount}}</span>
					</div>
				</div>
				<div class="item-group">
					<div class="item ui_border_t right" @click="openWin('./discovery/contact_win')">
						<i class="icon icon_contact"></i> 通讯录
						<span></span>
					</div>
					<!-- <div class="item ui_border_t right">
						<i class="icon icon_wzb"></i> 微支部
						<span></span>
					</div>
					<div class="item ui_border_t right">
						<i class="icon icon_zjhh"></i> 最近会话
						<span></span>
					</div> -->
				</div>
				<!-- <div class="item-group">
					<div class="item ui_border_t right">
						<i class="icon icon_zxhd"></i> 最新活动
						<span></span>
					</div>
				</div> -->
			</div>
		</div>
	</div>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/vue.min.js"></script>
	<script type="text/javascript" src="../script/common.js"></script>
	<script type="text/javascript" src="../script/layer_mobile/layer.js"></script>
	<script type="text/javascript">
		new Vue({
			el: '#app',
			data: {
				isLogin: false,
				msgCount: 0
			},
			mounted: function() {
				var $this = this;
				apiready = function() {
					api.setFrameAttr({
						name: api.frameName,
						hidden: true
					});
					var header = $api.dom('header');
					$api.fixStatusBar(header);

					$this.init();
					api.addEventListener({
						name: 'user_login_logout_event'
					}, function(ret, err) {
						$this.init();
					});
					api.addEventListener({
						name: 'refresh_newmessagecount_event'
					}, function(ret, err) {
						if ($this.isLogin) {
							$this.newMsgCount();
						}
					});
				}
			},
			methods: {
				newMsgCount: function() {
					var $this = this;
					post('/client/studyMoment/newMsgCount', {}, function(ret) {
						if (ret.isSuccess) {
							$this.msgCount = ret.data
						}
					})
				},
				init: function() {
					var $this = this;
					var userInfo = $api.getStorage(_.USERINFO);
					$this.isLogin = !!userInfo;

					if ($this.isLogin) {
						$this.newMsgCount();
					}
				},
				openWin: function(url) {
					openWin(this.isLogin ? url : 'login')
				}
			}
		});
	</script>
</body>

</html>
